﻿using System;
using UFSoft.UBF.Cust.ClassView.MVC.Resource;
using UFSoft.UBF.Sys.Database;
using UFSoft.UBF.Util.DataAccess;

namespace UFSoft.UBF.Cust.ClassView.MVC.SQL
{
    /// <summary>
    ///     SQL相关功能
    /// </summary>
    public static class SQLFuncHelper
    {
        /// <summary>
        ///     刷新全部枚举
        /// </summary>
        public static void RefreshAllEnum()
        {
            string strSql = ResourceHelper.GetFileContent("RefreshAllEnum.sql");
            if (string.IsNullOrEmpty(strSql))
                throw new Exception("读取刷新全部枚举资源文件异常");
            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), strSql, null);
        }

        /// <summary>
        ///     刷新单个枚举
        /// </summary>
        public static void RefreshSingleEnum(string enumFullName)
        {
            string strSql = ResourceHelper.GetFileContent("RefreshSingleEnum.sql");
            if (string.IsNullOrEmpty(strSql))
                throw new Exception("读取刷新单个枚举资源文件异常");
            strSql = strSql.Replace("{ EnumFullName }", enumFullName);
            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), strSql, null);
        }
    }
}